#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
int main() {
    char str[8000] = { 0 };
    long long int c_sum = 0, ch_sum = 0, chn_sum = 0;
    int i = 0;
    scanf("%s", str);
    for (i = 0; str[i] != '\0'; i++)
    {
        if (str[i] == 'C')
        {
            c_sum++;
        }
        else if (str[i] == 'H')
        {
            ch_sum += c_sum;
        }
        else if (str[i] == 'N')
        {
            chn_sum += ch_sum;
        }
    }
    printf("%lld", chn_sum);
    return 0;
}